package top.laoshuzi.common.base;

import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.os.Bundle;
import android.support.annotation.Nullable;

public abstract class CommonDataBindActivity<B extends ViewDataBinding> extends CommonActivity {

    B dataBinding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        dataBinding.unbind();
    }

    @Override
    public void initView() {
        super.initView();
        dataBinding = DataBindingUtil.setContentView(this, layoutId());
    }

    public B getBinding() {
        return dataBinding;
    }

    public abstract int layoutId();

}
